package com.reyco1.medusa.manager
{
	import adobe.utils.MMExecute;

	public class MMExecuteManager extends Object
	{
		public static function runScript(folderNameInConfig:String, fileName:String):void
		{
			var temp:String = "fl.runScript( fl.configURI + \""+ folderNameInConfig +"/\" + \""+ fileName +"\" )";
			MMExecute(temp);
		}
		
		public static function runMethod(folderNameInConfig:String, fileName:String, methodName:String, ...args):String
		{
			var head:String 	  = "fl.runScript( fl.configURI + \""+ folderNameInConfig +"/\" + \""+ fileName +"\", ";
			var method:String 	  = "\"" + methodName + "\"";
			var parameters:String = args.length > 0 || args[0] != "" ? parseArgs(args as Array) : "";
			var tail:String 	  = " )";
			
			return MMExecute( head + method + parameters + tail );
		}
		
		private static function parseArgs(args:Array):String
		{
			var head:String = "";
			for(var a:int = 0; a<args.length; a++)
			{
				head += ", \"" + args[a] + "\"";
			}
			return head;
		}
	}
}